<ui:composition
		xmlns="http://www.w3.org/1999/xhtml"
		xmlns:h="http://java.sun.com/jsf/html"
		xmlns:f="http://java.sun.com/jsf/core"
		xmlns:a4j="http://richfaces.org/a4j"
		xmlns:rich="http://richfaces.org/rich"
		xmlns:ui="http://java.sun.com/jsf/facelets"
		>
	<f:loadBundle basename="bundle.common" var="commonBundle"/>

	<!--<rich:modalPanel id="tableModelPanel">-->
		<!--<f:facet name="header">-->
			<!--<h:panelGroup>-->
				<!--<h:outputText value="Error message"></h:outputText>-->
			<!--</h:panelGroup>-->
		<!--</f:facet>-->
		 <!--<h:outputText value="Элемент не может быть удален!"/>-->
		<!--<h:panelGroup>-->
			<!--<br/>-->
			<!--<a4j:commandButton id="butCancel" value="Close">-->
				<!--<rich:componentControl for="tableModelPanel" attachTo="butCancel" operation="hide" event="onclick"/>-->
			<!--</a4j:commandButton>-->
		<!--</h:panelGroup>-->
	<!--</rich:modalPanel>-->

	<rich:panel id="#{idPrefix}TablePanel" styleClass="transparent">
		<a4j:form>
			<a4j:commandLink value="#{commonBundle.add}" action="#{actionBean.add}" reRender="#{idPrefix}TablePanel"
							 rendered="#{not actionBean.editMode}"/>
		</a4j:form>
		<a4j:form>
			<rich:panel id="#{idPrefix}AddPanel" rendered="#{actionBean.editMode}">
				<f:facet name="header">
					<h:panelGroup>
						<h:outputText value="#{commonBundle.adding} _#{idPrefix}_" rendered="#{actionBean.record.new}"/>
						<h:outputText value="#{commonBundle.editing} _#{idPrefix}_"
									  rendered="#{!actionBean.record.new}"/>
					</h:panelGroup>
				</f:facet>
				<ui:insert name="editPanelContext"/>
				<br/>
				<a4j:commandButton value="#{commonBundle.save}" action="#{actionBean.save}"
								   reRender="#{idPrefix}TablePanel"/>
				<a4j:commandButton value="#{commonBundle.cancel}" action="#{actionBean.cancel}"
								   reRender="#{idPrefix}TablePanel" immediate="true"/>
				<h:commandButton value="#{commonBundle.reset}" type="reset" rendered="false"/>
			</rich:panel>
		</a4j:form>
		<a4j:form>
			<table width="100%">
				<tr>
					<td width="15%">&#160;</td>
					<td width="70%">
						<rich:datascroller for="#{idPrefix}Table" reRender="#{idPrefix}TablePanel"
										   page="#{actionBean.currentPage}" renderIfSinglePage="false"/>
					</td>
					<td width="15%">
						<h:selectOneMenu value="#{actionBean.resultsPerPage}"
										 rendered="#{actionBean.resultsPerPageLookupVisible}">
							<f:selectItems value="#{actionBean.resultsPerPageLookup}"/>
							<a4j:support event="onchange" reRender="#{idPrefix}TablePanel" ajaxSingle="true"/>
						</h:selectOneMenu>
					</td>
				</tr>
				<tr>
					<td colspan="3">
						<rich:dataTable id="#{idPrefix}Table" width="100%" headerClass="dr-table-header"
										onRowMouseOver="this.style.backgroundColor='#f1f1f1';"
										onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}';"
										var="record" value="#{actionBean.dataModel}"
										binding="#{actionBean.tableBinding}" rows="#{actionBean.resultsPerPage}">
							<ui:insert name="tableContext"/>
							<rich:column width="1%">
								<f:facet name="header"><h:outputText value="#{commonBundle.action}"/></f:facet>
								<h:panelGroup style="white-space:nowrap;">
									<a4j:commandLink value="#{commonBundle.edit}" action="#{actionBean.edit}"
													 reRender="#{idPrefix}TablePanel" immediate="true"/>
									<rich:spacer width="7"/>
									<a4j:commandLink id="delLink" value="#{commonBundle.delete}" action="#{actionBean.delete}"
													 reRender="#{idPrefix}TablePanel" immediate="true"/>
								</h:panelGroup>
							</rich:column>
						</rich:dataTable>
					</td>
				</tr>
				<tr>
					<td width="15%">&#160;</td>
					<td width="70%">
						<rich:datascroller for="#{idPrefix}Table" reRender="#{idPrefix}TablePanel"
										   page="#{actionBean.currentPage}" renderIfSinglePage="false"/>
					</td>
					<td width="15%">
						<h:selectOneMenu value="#{actionBean.resultsPerPage}"
										 rendered="#{actionBean.resultsPerPageLookupVisible}">
							<f:selectItems value="#{actionBean.resultsPerPageLookup}"/>
							<a4j:support event="onchange" reRender="#{idPrefix}TablePanel" ajaxSingle="true"/>
						</h:selectOneMenu>
					</td>
				</tr>
			</table>
		</a4j:form>
	</rich:panel>

</ui:composition>